import React from 'react';

import CommonRequestDataAction from '../common/CommonRequestDataAction';
import Constants from '../../common/Constants';

export default class UserRequestSaerchListAction extends CommonRequestDataAction {
    constructor() {
      super();

      this.moduleType = Constants.MODULE_TYPE.USER;
      this.name = "UserRequestSaerchListAction";
    }
    finish(data, isSucceed, response) {
      const type = this.data.type?this.data.type:'';
      if(isSucceed) {
      	if (type.length>0) {
      	  var arr = [];
      	  if (type==='news') {
      		arr=data.news;
      	  }else if (type==='activities') {
      		arr=data.activities;
      	  }else if (type==='lovers') {
      		arr=data.lovers;
      	  }else if (type==='posts') {
      		arr=data.posts;
      	  }else if (type==='innovation') {
      		arr=data.innovation;
      	  }
      	  this.caller.setState({viewStatus: 3,isResponeUpdate: true,data:arr})
      	}else{
			     this.caller.setState({viewStatus: 3,isResponeUpdate: true,data:data})
      	}
        this.onFinishSuccess(data, response);
      }
      else if (response) {
        if(response.status == 401) {
          this._dealUnauthorized(this.caller);
        }
        else {
          this.caller.setState({viewStatus: response.status})
        }
      }
      else {
        this.caller.setState({viewStatus: 400})
      }
    }

}
